let arr = [1,2,,null,[3,4,[5,6,[7,8]]]]
//some + isArray + 迭代
//完美实现
Array.prototype.myFlat = function(deep=1){
    if(deep<=0) return this
    let res = this
    while(deep&&
        res.some(
            item=>Array.isArray(item))){
                //使用filter去除空格
                res=[].concat(...res).filter((i)=>i!==undefined)
                deep--
            }
    return res
}
console.log(arr.myFlat(1));
console.log(arr.myFlat(2));
console.log(arr.myFlat(3));